package com.jinsilu.freight.helper;

import android.content.Context;
import android.widget.ImageView;

import androidx.annotation.DrawableRes;

import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.jinsilu.freight.http.glide.GlideApp;
import com.jinsilu.freight.ui.activity.ImagePreviewActivity;

import java.util.ArrayList;

public class ShowImageHelper {

    public static void showNormal(Context context, String url, ImageView imageView) {
        GlideApp.with(context)
                .load(url)
                .centerCrop()
                .into(imageView);
    }

    public static void showNormal(Context context, @DrawableRes int url, ImageView imageView) {
        GlideApp.with(context)
                .load(url)
                .centerCrop()
                .into(imageView);
    }

    public static void showNormalRound(Context context, String url, ImageView imageView, int radius) {
        GlideApp.with(context)
                .load(url)
                .transform(new CenterCrop(), new RoundedCorners(radius))
                .into(imageView);
    }

    public static void showNormal(Context context, @DrawableRes int url, ImageView imageView, int radius) {
        GlideApp.with(context)
                .load(url)
                .transform(new CenterCrop(), new RoundedCorners(radius))
                .into(imageView);
    }

    public static void showCircle(Context context, String url, ImageView imageView) {
        GlideApp.with(context)
                .load(url)
                .centerCrop()
                .circleCrop()
                .into(imageView);
    }

    /**
     * 查看图片
     *
     * @param image 图片地址
     */
    public static void showImageView(Context context, String image) {
        ArrayList<String> images = new ArrayList<>();
        images.add(image);
        ImagePreviewActivity.start(context, images, images.size() - 1);
    }
}
